﻿@{
    ViewBag.Title = "查询添加业务系统";
    Layout = "~/Views/Shared/PlanPartial/_LayoutSearch.cshtml";
}

@{
    var Key = ViewData["Key"] as string;
}
<div>
    <input type="hidden" value="@(Key)" id="searchKey" />
    <input type="text" style="width: 280px;" value="@(Key)" class="easyui-searchbox" data-options="prompt:'输入业务系统名称或者IP地址进行搜索',searcher:doSearch" />
</div>
<div style="padding: 10px 0;">
    <table id="businessSearch" style="height: auto;" class="" title="搜索结果"
        fitcolumns="true" singleselect="false" pagination="true">
        <thead>
            <tr>
                <th data-options="field:'ck',checkbox:true">全选</th>
                <th field="Request_ID" hidden="true"></th>
                <th field="AppSystemName" width="160" sortable="true">业务系统名称</th>
                <th field="IPAddress" width="160" sortable="true">IP地址</th>
            </tr>
        </thead>
    </table>
</div>

<script type="text/javascript">
    //调用后台搜索
    var doSearch = function (value) {
        var parenter = GetParentWindow(),
            list = [];
        if (parenter) {
            list = parenter.InspObj.GetRequestIDList('BusinessSystems');
        }

        var query = { Key: value, ExcludeIDList: JSON.stringify(list) };
        $('#businessSearch').datagrid('load', query);
    };

    //向父页面对应列表中添加数据
    var AddRow = function () {
        var parenter = GetParentWindow();

        if (parenter) {
            var selects = parenter.InspObj.SelectArray["businessSearch"] || [];

            if (selects.length) {
                parenter.InspObj.AddBusinessSys(selects);
                parenter.InspObj.SelectArray["businessSearch"] = [];
                closeWindow();
            }
        }
    };

    $(function () {
        var parenter = GetParentWindow(),
            list = [];
        if (parenter) {
            list = parenter.InspObj.GetRequestIDList('BusinessSystems');
        }

        var query = { Key: $('#searchKey').val(), ExcludeIDList: JSON.stringify(list) };

        $('#businessSearch').datagrid({
            url: '/PlanManagement/SearchBusinessResult',
            dataType: "json",
            pageList: [10],
            pageSize: 10,
            pageNumber: 1,
            queryParams: query,
            onLoadSuccess: function (data) {
                parenter.InspObj.onLoadSuccess(data.rows, "businessSearch", $('#businessSearch'));
            },
            onCheck: function (index, row) {
                parenter.InspObj.OnSelect(index, row, "businessSearch");
            },
            onUncheck: function (index, row) {
                parenter.InspObj.OnUnSelect(index, row, "businessSearch");
            },
            onCheckAll: function (rows) {
                parenter.InspObj.OnSelectAll(rows, "businessSearch");
            },
            onUncheckAll: function (rows) {
                parenter.InspObj.OnUnSelectAll(rows, "businessSearch");
            }
        });

        var p2 = $('#businessSearch').datagrid('getPager');
        $(p2).pagination({
            beforePageText: '第',
            afterPageText: '页&nbsp;共&nbsp;{pages}&nbsp;页',
            displayMsg: '当前显示{from} - {to}&nbsp;条记录&nbsp;共&nbsp;{total}&nbsp;条记录'

        });
    });
</script>

